<template>
<div>
  <el-form label-width="60px" :model="person" style="padding: 20px 30px">
    <el-form-item label="姓名：">
      <el-input v-model="person.name" />
    </el-form-item>
    <el-form-item label="性别：">
      <el-radio-group v-model="person.sex" @change="">
        <el-radio label="1" size="large" border>男</el-radio>
        <el-radio label="0" size="large" border>女</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="电话：">
      <el-input v-model="person.tel" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="">提交</el-button>
      <el-button type="info" @click="closeAdd()">取消</el-button>
    </el-form-item>
  </el-form>
</div>
</template>

<script>
export default {
  name: "add",
  props: {   //接收父组件传过来的值
    addView:{
      type: Boolean,
      default: true   //默认是true
    },
    // required: true
  },
  data(){
    let person={
      id: '',
      name: '',
      sex: '',
      tel: ''
    }
    return{
      addView: false,
      person
    }
  },
  methods:{
    closeAdd(){
      this.$emit("func",false);
    }
  },
  watch:{
    addView1(newVal,oldVal){   //监听父组件中addView传过来的值是否变化，来是否启动
      this.addView = newVal;
    }
  }
}
</script>

<style scoped>

</style>
